<template>
  <div class="container">
    <iframe :src="url" ref="iframe"></iframe>
    <!--        <iframe style="overflow:hidden;width:0;height:0;border:none;flex:0" :src="url2"></iframe>-->
  </div>
</template>
<style>
.container, .container iframe {
  display: flex;
  flex-direction: column;
  flex: 1;
}

iframe {
  border: none;
}

</style>
<script type="text/ecmascript-6">

import {mapState, mapMutations, mapActions, mapGetters} from 'vuex'

export default {
  data: function () {
    return {
      url: "",
      url2: "",
    }
  },
  mounted() {
    console.log(this.$store.state.name)
  },
  watch: {
    "$store.state.version"() {
      this.$nextTick(() => {
        var name = this.$store.state.name;

        if (name === "gitea") {
          this.url = "http://127.0.0.1:408/dev/gitea.html?token=" + jv.token + "&_=" + jv.random();
        } else if (name === "jenkins") {
          this.url = "http://127.0.0.1:508/dev/jenkins.html?token=" + jv.token + "&_=" + jv.random();
        } else if (name === "grafana") {
          this.url = "http://127.0.0.1:608/dev/grafana.html?token=" + jv.token + "&_=" + jv.random();
        }else if (name === "confluence") {
          this.url = "http://127.0.0.1:708/dev/confluence.html?token=" + jv.token + "&_=" + jv.random();
        }else if (name === "sonarqube") {
          this.url = "http://127.0.0.1:808/dev/sonarqube.html?token=" + jv.token + "&_=" + jv.random();
        }
      });
    }
  },
  methods: {
    ifr_load() {
      // this.$refs.iframe.contentWindow.name = jv.token;
    },
    /*    autoLogin() {
          let i = document.querySelector("#app > div.container > iframe")
          //请求接口 获取用户名 密码  注入
          i.contentWindow.postMessage("cy&!QAZ2wsx", '*');
          console.log("执行注入")
        },*/
    // loginGitea() {
    //     this.$http.get("/open/giteaLogin").then(res => {
    //     })
    // }
  }
}
</script>

<style scoped>
</style>
